#ifdef _WIN32
	#include "ServerWin.h"
#else
	#include <unistd.h>
	#include "ServerUnix.h"
#endif
#include <sstream>
#include <stdlib.h>
#include "Connection.hpp"


Connection::Connection()
{

}

Connection::~Connection()
{
}


void				Connection::close()
{
	std::string			sc;

	sc = _infoClient.first;
	std::cout << "CliSock = " << sc.c_str() << std::endl;
#ifdef _WIN32
	closesocket(atoi(sc.c_str()));
#else
	::close(atoi(sc.c_str()));
#endif
}


void				Connection::StockCliInfo(int sc, unsigned int ip)
{
	std::ostringstream	oss;
	std::ostringstream	osss;
	std::string			temp;

	oss << sc;
	temp = oss.str();
	_infoClient.first = temp;
	osss << ip;
	temp = osss.str();
	_infoClient.second = temp;
	send(sc, "test\0", 5, 0);
}

const	std::string	Connection::getSocket()
{
	return (_infoClient.first);
}
/*ssize_t	Connection::SendToCli(api::Resource, void *buf, size_t len)
{
	int	sc;
	std::string	str;

	//str = ((*mInfos)["CliSock"]);
	sc = atoi(str.c_str());
	send(sc, (char *)buf, len, 0);
	return (0);
}

ssize_t	Connection::RecvFromCli(api::Resource, void *buf, size_t len)
{
	int	sc;
	std::string	str;

	//str = ((*mInfos)["CliSock"]);
	sc = atoi(str.c_str());
	recv(sc, (char *)buf, len, 0);
	return (0);
}*/

